package com.junit;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.RestTemplate;

import com.Application;
import com.alibaba.fastjson.JSON;
import com.service.IUserService;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
// @WebIntegrationTest({"server.port=0", "management.port=0"})
// @WebAppConfiguration
public class StudentTest {
    @Autowired
    IUserService userService;
    @Rule
    public OutputCapture capture = new OutputCapture();

    TestRestTemplate template = new TestRestTemplate();

    @Test
    public void likeName() {
        System.out.println(JSON.toJSONString(userService.getUserById(3l)));
    }

    @Test
    public void testName() throws Exception {
        System.out.println("Hello World!");
        System.out.println(capture.toString());
        // assertThat(capture.toString(), containsString("World"));
    }

    @Test
    public void testRequest() throws Exception {
        HttpHeaders headers = template.getForEntity("http://www.baidu.com", String.class).getHeaders();
        System.out.println(headers.getContentLength());
    }
}